<%@page import="com.muk.meis.model.bean.UserProfile"%>
<%@page import="com.muk.meis.MEISConstance"%>
<%@page import="java.util.List"%>
<%@page import="java.util.Iterator"%>
<%@page import="com.muk.meis.model.service.SchoolInfoService"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>MEIS</title>
<link href="layout.css" rel="stylesheet" type="text/css">
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="js/flot/excanvas.min.js"></script><![endif]-->
<link href="css/dropdown/themes/default/helper.css" media="screen" rel="stylesheet" type="text/css" />
<!-- Beginning of compulsory code below -->

<link href="css/dropdown/dropdown.css" media="screen" rel="stylesheet" type="text/css" />
<link href="css/dropdown/themes/default/default.css" media="screen" rel="stylesheet" type="text/css" />

<link type="text/css" href="css/redmond/jquery-ui-1.8.16.custom.css" rel="stylesheet" />	
<script type="text/javascript" src="js/jquery/jquery.js"></script>
<script type="text/javascript" src="js/jquery/jquery-ui-1.8.16.custom.min.js"></script>

<!--[if lt IE 7]>
<script type="text/javascript" src="js/jquery/jquery.js"></script>
<script type="text/javascript" src="js/jquery/jquery.dropdown.js"></script>
<![endif]-->

<!-- / END -->

<script language="javascript" type="text/javascript"
	src="js/flot/jquery.flot.js"></script>

<style type="text/css">
.mesi_header_m {
	color: #F00;
}
</style>

<script>
	$(function() {
		$( "input:submit").button();
	});
</script>
</head>
<body>
	
       <%
       UserProfile userPassLogin =  (UserProfile)session.getAttribute(MEISConstance.USER_PASS_LOGIN);
       if(userPassLogin == null){
       %>
       <div style="position:relative;background-image: url('image/header_background.gif'); width: 1000px; height:140px; color: #333;font-size:25px;">
           <div style="width:800px; padding-left:50px;padding-top:50px;"><span class="mesi_header_m">M</span>ukdahan education information system</div>
       </div>
       

       <div>
       	   <table>
       	   	  <tr>
       	   	  	<td>
			       <div style="position: relative;padding-top: 10px;">
			       	  <img width="150px" height="55px" src="image/banner_ubu.jpg"/>
			       </div>       	   	  	
       	   	  	</td>
       	   	  	<td>
					<div style="position:relative;background-repeat:no-repeat;padding-top:20px;padding-left:10px;">
						<ul id="nav" class="dropdown dropdown-horizontal">
							<li>เกี่ยวกับโครงการ
								<ul>
									<li>ความเป็นมา</li>
									<li>วัตถุประสงค์</li>
								</ul>
							</li>	
							<li><a href="school.jsp">คณะผู้จัดทำ</a></li>
							<li><a href="scale.jsp">ติดต่อเรา</a></li>
						</ul>
					</div>
       	   	  	</td>
       	   	  </tr>
       	   </table>
       </div>
       
       
       
       <div style="position:relative;padding-top:15px;width:1000px;"> 

           <form action="index.jsp">
		   <div style="position: relative;padding-left: 480px;padding-bottom: 20px;">
		   		<table>
			   		<tr>
			   			<td>โรงเรียน</td>
			   			<td><input type="text" name="search"/></td>
			   			<td style="position: relative;padding-left: 5px;"><input type="submit" name="butsearch" 
			   			style="position: relative;padding-bottom: 21px;width: 55px;height: 25px;font-size: 85%" value="ค้นหา "/>
			   			</td>
			   		</tr>
		   		</table>
		   </div>
		   </form>
		   
	       <table>
	       		<tr>
	       		<td valign="top">
	       		   <form action="LoginController/login">
				       <div style="position: relative;padding-top: 10px;">
				       <%
				       String errormsg = request.getParameter("errormsg");
				       if(errormsg != null){
				       %>	   
				    	  <span style="position:relative;color: red;font-size: 18px;left: 15px;bottom: 10px;"><%=errormsg%></span>
				       <%}%>	        
				       	  <div class="ui-widget-header" style="height: 30px;">
				       	  	<span style="position: relative;top: 5px;padding-left: 10px;">เข้าใช้</span>
				       	  </div> 
				       	  <table style="position: relative; padding-top: 10px;">
				       	  	<tr>
				       	  		<td>ชื่อผู้ใช้</td>
				       	  		<td><input type="text" name="username" width="10"/></td>
				       	  	</tr>
				       	  	<tr style="position:relative;padding-top:10px;">
				       	  		<td>รหัสผ่าน</td>
				       	  		<td><input type="password" name="password" width="10"/></td>
				       	  	</tr>
				       	  </table>
				       	  <div style="position: relative;padding-top: 10px;">
				       	  	<input type="submit" name="ok" value="ตกลง" style="font-size: 85%"/>
				       	  </div>
				       </div>
			       </form>	       		
	       		</td>

	       		<td>
			          <div style="position: relative;padding-left: 150px;">
				       <%} else {%>		           
				          <jsp:include page="menu.jsp"></jsp:include>
				          <div style="position:relative;padding-top:60px;padding-left:300px;">
				       <%} %>
					       <table id="mainTable" cellspacing="0">
					            <tr style="background-image:url(image/header_table_background.jpg);" height="30px;">
					                <td align="center">ลำดับ </td>
					                <td align="center" width="80px">รหัสโรงเรียน</td>                                               
					                <td align="center">ชื่อโรงเรียน</td>                                               
					                <td align="center">ตำบล</td>                                               
					            </tr>
						       <%
						       String schoolName = request.getParameter("search");
						       SchoolInfoService schoolInfoService = new SchoolInfoService();
						       List lst = schoolInfoService.getSchoolName(schoolName);
						       int couter = 1;
						       for (Iterator iterator = lst.iterator(); iterator.hasNext();) {
						    	   Object [] schoolInfo = (Object[]) iterator.next();
						       %>
						           <tr>
							           		<td align="center"><a href="<%="NewsController/list?percode="+schoolInfo[3]%>"><%=couter++%></a></td>
							           		<td align="center"><a href="<%="NewsController/list?percode="+schoolInfo[3]%>"><%=schoolInfo[3]%></a></td>
							           		<td><a href="<%="NewsController/list?percode="+schoolInfo[3]%>"><%=schoolInfo[0]%></a></td>
							           		<td><a href="<%="NewsController/list?percode="+schoolInfo[3]%>"><%=schoolInfo[1]%></a></td>
						           </tr>
						       <%} %>
					       </table>
				         </div> 
				     <%if(userPassLogin == null){ %>
			           </div>
			         <%} %>	       		
	       		</td>
	       		</tr>
	       </table> 
         <jsp:include page="footer.jsp"></jsp:include>		                 
	
</body>
</html>